def factorial(n):
    if n < 0:
        return "阶乘未对负数定义"
    elif n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n - 1)

while True:
    num=int(input("请输入一个整数:"))
    if num==0:
        break
    result=factorial(num)
    print(result)